package com.easyder.wrapper.widget;

import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.view.Gravity;
import android.widget.LinearLayout;

import com.easyder.wrapper.R;
import com.easyder.wrapper.base.adapter.ViewHelper;
import com.easyder.wrapper.base.view.WrapperDialog;
import com.easyder.wrapper.utils.UIUtils;

/**
 * Auther:  winds
 * Data:    2018/5/3
 * Version: 1.0
 * Desc:
 */


public class LoadingDailog extends WrapperDialog {

    public LoadingDailog(Context context) {
        super(context);
    }

    @Override
    public int getLayoutRes() {
        return R.layout.dialog_loading;
    }

    @Override
    protected void setDialogParams(Dialog dialog) {
        setDialogParams(dialog, Gravity.CENTER);
        setOrientation(LinearLayout.HORIZONTAL);
    }

    @Override
    public void help(ViewHelper helper) {
        helper.setBackgroundDrawable(R.id.loading_view, new ColorDrawable(Color.parseColor("#FFFFFF")).setRoundCorner(UIUtils.dip2px(5), UIUtils.dip2px(5)));
    }

    public LoadingDailog setOrientation(int orientation) {
        if (helper != null) {
            ((LinearLayout) helper.getView(R.id.loading_view)).setOrientation(orientation);
            if (orientation == LinearLayout.HORIZONTAL) {
                helper.getView(R.id.loading_message).setPadding(UIUtils.dip2px(8), 0, 0, 0);
            } else {
                helper.getView(R.id.loading_message).setPadding(0, UIUtils.dip2px(8), 0, 0);
            }
        }
        return this;
    }

}
